Ext.define('DCApp.view.building.Detail', {
	extend : 'DCApp.view.Detail',
	alias : 'widget.buildingdetail',

	requires: ['DCApp.ux.ComboTree'],
	bind : {
		title : '古建 - 【{theObj.objId}】'
	},

	componentCls : 'building-detail',
	bodyPadding : 0,

	controller : 'buildingdetail',
	viewModel : {
		type : 'buildingdetail'
	},

	tbar : ['->', {
				text : '保存',
				handler : 'onSaveClick'
			}, {
				text : '返回',
				handler : 'onBackClick'
			}],
	afterRender : function(ct, position) {
		var imgpanel = this.down('imgpanel');
		var tb = imgpanel.down('toolbar[dock=top]');
		tb.insert(1, {
					text : '插入'
				});
		var attachpanel = this.down('attachpanel');
    	tb = attachpanel.down('toolbar[dock=top]');
    	tb.insert(1,[{
    		text:'插入'
    	}]);		
		this.callParent();
	},
	items : [{
				id : 'panel0',
				listeners : {
					render : function(p) {
						p = p.getEl();
						var me = this.up();
						me.h0 = p.getHeight();
						p.on('scroll', function(e, t) {
							me.onscroll(t.scrollTop, t.clientHeight);
						}, p);
					}
				},
				title : 'Panel 0',
				flex : 2,
				frame : false,
				xtype : 'container',
				layout : 'anchor',
				style : {
					overflow : 'auto'				},
				items : [
						{
							title : '古建信息',
							margin : '0 0 10 0',
							cls : 'nav_pos',
							reference : 'form',
							bodyPadding : 10,
							fieldDefaults : {
								labelAlign : 'right',
								labelWidth : 100,
								padding : 3
							},
							defaults : {
								anchor : '100%'
							},
							xtype: 'form',
                    		items: [
                    			{                    				
                    				xtype: 'container',
			                        layout: 'hbox',
			                        combineErrors: true,
			                        defaultType: 'textfield',
			                        items:[
					                    {
					                    	flex: 1,
					                        fieldLabel: '撰稿人',
					                        allowBlank: false,
					                        bind: '{theObj.author}',
					                        publishes: ['value']
					                    },
					                    {
			                        		flex: 1,
					                        fieldLabel: '分类',
					                        allowBlank: false,
					                        bind: '{theObj.className}',
					                        publishes: ['value'],
					                        xtype: 'combotree',
				                			storeUrl : 'resources/tree_single.json',
				                			cascade : 'child',
				                			checkModel:'single',
				                			width : 270,
				                			rootId : '1',
				                			rootText : 'DRP',
				                			treeNodeParameter : ''
					                    }	                        
			                		]
                    			},
                    			{                    				
                    				xtype: 'container',
			                        layout: 'hbox',
			                        combineErrors: true,
			                        defaultType: 'textfield',
			                        items:[
					                    {
					                    	flex: 1,
					                        fieldLabel: '区域',
					                        allowBlank: false,
					                        bind: '{theObj.objProdarea}',
					                        publishes: ['value'],
					                        xtype: 'combotree',
				                			storeUrl : 'resources/tree_single.json',
				                			cascade : 'child',
				                			checkModel:'single',
				                			width : 270,
				                			rootId : '1',
				                			rootText : 'DRP',
				                			treeNodeParameter : ''
					                    },
					                    {
			                        		flex: 1,
					                        fieldLabel: '古建编号',
					                        allowBlank: false,
					                        bind: '{theObj.objNo}',
					                        publishes: ['value']
					                    }	                        
			                		]
                    			},
                    			{                    				
                    				xtype: 'container',
			                        layout: 'hbox',
			                        combineErrors: true,
			                        defaultType: 'textfield',
			                        items:[
					                    {
					                    	flex: 1,
					                        fieldLabel: '古建名称',
					                        allowBlank: false,
					                        bind: '{theObj.objName}',
					                        publishes: ['value']
					                    },
					                    {
			                        		flex: 1,
					                        fieldLabel: '建筑年代',
					                        allowBlank: false,
					                        bind: '{theObj.generateEra}',
					                        publishes: ['value']
					                    }	                        
			                		]
                    			},
                    			{                    				
                    				xtype: 'container',
			                        layout: 'hbox',
			                        combineErrors: true,
			                        defaultType: 'textfield',
			                        items:[
					                    {
					                    	flex: 1,
					                        fieldLabel: '备注',
					                        allowBlank: false,
					                        bind: '{theObj.note}',
					                        publishes: ['value']
					                    },
					                    {
			                        		flex: 1,
					                        fieldLabel: '关键词',
					                        allowBlank: false,
					                        bind: '{theObj.keywords}',
					                        publishes: ['value']
					                    }
			                		]
                    			},
                    			{                    				
                    				xtype: 'container',
			                        layout: 'hbox',
			                        combineErrors: true,
			                        defaultType: 'textfield',
			                        items:[
					                    {
					                    	flex: 1,
					                        fieldLabel: '中文名称',
					                        allowBlank: false,
					                        bind: '{theObj.nameCn}',
					                        publishes: ['value']
					                    },
					                    {
			                        		flex: 1,
					                        fieldLabel: '英文名称',
					                        allowBlank: false,
					                        bind: '{theObj.nameUk}',
					                        publishes: ['value']
					                    }
			                		]
                    			},
                    			{                    				
                    				xtype: 'container',
			                        layout: 'hbox',
			                        combineErrors: true,
			                        defaultType: 'textfield',
			                        items:[
					                    {
					                    	flex: 1,
					                        fieldLabel: '中文别名',
					                        allowBlank: false,
					                        bind: '{theObj.briefCn}',
					                        publishes: ['value']
					                    },
					                    {
			                        		flex: 1,
					                        fieldLabel: '名称沿革',
					                        allowBlank: false,
					                        bind: '{theObj.namehistory}',
					                        publishes: ['value']
					                    }
			                		]
                    			},
                    			{                    				
                    				xtype: 'container',
			                        layout: 'hbox',
			                        combineErrors: true,
			                        defaultType: 'textfield',
			                        items:[
					                    {
					                    	flex: 1,
					                        fieldLabel: '所属区域场景',
					                        allowBlank: false,
					                        bind: '{theObj.areascene}',
					                        publishes: ['value']
					                    },
					                    {
			                        		flex: 1,
					                        fieldLabel: '宫殿等级',
					                        allowBlank: false,
					                        bind: '{theObj.palacegrade}',
					                        publishes: ['value']
					                    }
			                		]
                    			},
                    			{                    				
                    				xtype: 'container',
			                        layout: 'hbox',
			                        combineErrors: true,
			                        defaultType: 'textfield',
			                        items:[
					                    {
					                    	flex: 1,
					                        fieldLabel: '基本形制描述',
					                        allowBlank: false,
					                        bind: '{theObj.shapesdesc}',
					                        publishes: ['value']
					                    },
					                    {
			                        		flex: 1,
					                        fieldLabel: '建筑数据',
					                        allowBlank: false,
					                        bind: '{theObj.buildingdata}',
					                        publishes: ['value']
					                    }
			                		]
                    			},
                    			{                    				
                    				xtype: 'container',
			                        layout: 'hbox',
			                        combineErrors: true,
			                        defaultType: 'textfield',
			                        items:[
					                    {
					                    	flex: 1,
					                        fieldLabel: '现用途',
					                        allowBlank: false,
					                        bind: '{theObj.nowuse}',
					                        publishes: ['value']
					                    },
					                    {
			                        		flex: 1,
					                        fieldLabel: '摘要',
					                        allowBlank: false,
					                        bind: '{theObj.introduction}',
					                        publishes: ['value']
					                    }
			                		]
                    			},
				                {
				            		xtype: 'htmleditor',
				            		bind: '{theObj.description}',
				            		publishes: ['value'],
				            		fieldLabel: '正文内容'                    		                    		
				               	}
		                    ]            
						},
						{
							title : '相关影像',
							margin : '0 0 10 0',
							cls : 'nav_pos',
							layout : 'fit',
							items : [
								{
									bind: '{theObj.images}',
			                    	xtype:'imgpanel',
			                    	btns:['关联','删除']
								}
							]
						},
						{
							title : '相关论文',
							margin : '0 0 10 0',
							cls : 'nav_pos',
							layout : 'fit',
							items : [
								{
								 bind: '{theObj.theses}',
								 xtype : 'thesislist',
								 plugins: null,
								 tbar: ['->',{
								        text: '关联',
								        handler: 'onRelThesis'
								    },{
								        text: '删除',
								        handler: 'onDelThesis'
								    }]
								}
							]							
						},
						{
							title : '相关文稿',
							margin : '0 0 10 0',
							cls : 'nav_pos',
							layout : 'fit',
							items : [
								{
									bind: '{theObj.docs}',
									xtype : 'doclist',
									plugins: null,
								 	tbar: ['->',{
								        text: '关联',
								        handler: 'onRelDoc'
								    },{
								        text: '删除',
								        handler: 'onDelDoc'
								    }]
								}
							]							
						},
		                {
		                    title: '附件列表',
		                    cls:'nav_pos',
		                    layout:'fit',
		                    items:[{
		                    	bind:'{theObj.ceAttachments}',
		                    	xtype:'attachpanel'
		                    }]                    
		                },
						{
							title : '相关文物',
							margin : '0 0 10 0',
							cls : 'nav_pos',
							layout : 'fit',
							items : [
								{
								 bind: '{theObj.relics}',
								 xtype : 'reliclist',
								 plugins: null,
								 tbar: ['->',{
								        text: '关联',
								        handler: 'onRelRelic'
								    },{
								        text: '删除',
								        handler: 'onDelRelic'
								    }]
								}
							]							
						}
						
					]
				}
			]
});
